#!/bin/bash

###############################################################################
# Name:        sh_func_t.sh
# Purpose:     usual functions of bash code
# Author:      Bright Li
# Modified by:
# Created:     2018-05-22
# Version:     [0.0.1]
# RCS-ID:      $$
# Copyright:   (c) Bright Li
# Licence:
###############################################################################

###################
# getopt usage:

function help(){
    echo "Usage : link-bin [-t Target] []"
    echo -e "\t-h:\t\t Help information"
    echo -e "\t-t Target:\t param of Target file, path from local/scripts/"
}

# while getopts :ab:c arg; do  # "ab:c"
set -- $(getopt -q ab:cd "$@")
while [ -n "$1" ]
do
    case "$1" in
        -a) echo "Found the -a option" ;;
        -b) param="$2"
            echo "Found the -b option, with parameter value: $param"
            shift ;;
        -c) echo "Found the -c option" ;;
        --) shift
            break ;;
        * ) echo "$1 is not option";;
    esac
    shift
done

count=1
for param in "$@"
do 
    echo "Parameter #$count: $param"
    count=$[$count + 1]
done


###################
# getopts

while getopts :ab:c arg; do  # "ab:c"
    case $arg in
        a) echo "Found the -a option" ;;
        b) echo "Found the -b option, with parameter value: $OPTARG" ;;
        c) echo "Found the -c option" ;;
        ?) echo "Unknown option: $OPTARG" ;;
    esac
done